package com.springcloud3.listener;

import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.time.Duration;

/**
 * 1.先从META-INF中读掉spring.factories
 * springboot 应用生命周期监听
 */

public class MyappListener  implements SpringApplicationRunListener {
    @Override
    public void starting(ConfigurableBootstrapContext bootstrapContext) {

        System.out.println("=============starting============");
    }



    @Override
    public void environmentPrepared(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment) {
        System.out.println("=============environmentPrepared============");
    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {
        System.out.println("=============contextPrepared============");
    }

    @Override
    public void contextLoaded(ConfigurableApplicationContext context) {
        System.out.println("=============contextLoadedd============");
    }

    @Override
    public void started(ConfigurableApplicationContext context, Duration timeTaken) {
        System.out.println("============tarted============");
    }

    @Override
    public void ready(ConfigurableApplicationContext context, Duration timeTaken) {
        System.out.println("=============ready============");
    }

    @Override
    public void failed(ConfigurableApplicationContext context, Throwable exception) {
        System.out.println("=============failed============");
    }
}
